﻿// JScript File

function createIMSToos()
{
//    var divTools        = document.createElement("div");
    
    var divZoomIn       = document.createElement("div");
    var divZoomOut      = document.createElement("div");
    var divPanLeft      = document.createElement("div");
    var divPanRight     = document.createElement("div");
    var divPanUp        = document.createElement("div");
    var divPanDown      = document.createElement("div");
    var divLastView     = document.createElement("div");
    var divZoomTree     = document.createElement("div");
    var divZoomSlider   = document.createElement("div");

    $(divZoomIn).width(17);
    $(divZoomOut).width(17);
    $(divPanLeft).width(17);
    $(divPanRight).width(17);
    $(divPanUp).width(17);
    $(divPanDown).width(17);
    $(divLastView).width(17);
    $(divZoomTree).width(17);
    $(divZoomSlider).width(17);

    $(divZoomIn).height(17);
    $(divZoomOut).height(17);
    $(divPanLeft).height(17);
    $(divPanRight).height(17);
    $(divPanUp).height(17);
    $(divPanDown).height(17);
    $(divLastView).height(17);
    $(divZoomTree).height(17);
    $(divZoomSlider).height(17);
    
//    $(divZoomIn).height(18);
//    $(divZoomOut).height(18);
//    $(divPanLeft).css("float","left");
//    $(divPanRight).css("float","left");
//    $(divPanUp).height(18);
//    $(divPanDown).height(18);
//    $(divLastView).css("float","left");
//    $(divZoomTree).height(18);
//    $(divZoomSlider).height(18);


    
    var imgZoomIn       = document.createElement("img");
    var imgZoomOut      = document.createElement("img");
    var imgPanLeft      = document.createElement("img");
    var imgPanRight     = document.createElement("img");
    var imgPanUp        = document.createElement("img");
    var imgPanDown      = document.createElement("img");
    var imgLastView     = document.createElement("img");
    var imgZoomTree     = document.createElement("img");
    var imgZoomSlider   = document.createElement("img");
    
    imgZoomIn.src       = "images/ZoomIn.gif";
    imgZoomOut.src      = "images/ZoomOut.gif";
    imgPanLeft.src      = "images/PanLeft.gif";
    imgPanRight.src     = "images/PanRight.gif";
    imgPanUp.src        = "images/PanUp.gif";
    imgPanDown.src      = "images/PanDown.gif";
    imgLastView.src     = "images/LastView.gif";
    imgZoomTree.src     = "images/ZoomTree.gif";
    imgZoomSlider.src   = "images/ZoomSlider.gif";

    imgZoomIn.alt       = "放大";
    imgZoomOut.alt      = "缩小";
    imgPanLeft.alt      = "向左移动";
    imgPanRight.alt     = "向右移动";
    imgPanUp.alt        = "向上移动";
    imgPanDown.alt      = "向下移动";
    imgLastView.alt     = "上一视图";
    imgZoomTree.alt     = "缩放级别";
    imgZoomSlider.alt   = "缩放滑块";
    
    divZoomIn.appendChild(imgZoomIn);
    divZoomOut.appendChild(imgZoomOut);
    divPanLeft.appendChild(imgPanLeft);
    divPanRight.appendChild(imgPanRight);
    divPanUp.appendChild(imgPanUp);
    divPanDown.appendChild(imgPanDown);
    divLastView.appendChild(imgLastView);
    
    var i = 0;
    var offsetTop = 0;
    var offsetLeft = 0;
    var mapElem = $("#map");
    
    for (var elem = mapElem; elem; elem = elem.offsetParent()) 
    {
        offsetTop += elem.offset().top;
        offsetLeft += elem.offset().left;
        i++;
        if (i>10) break;
    }
    offsetTop += 10;
    offsetLeft += 10;
    
    with($(divPanUp))
    {
        css("position","absolute");
        css("left",offsetLeft + 20);
        css("top",offsetTop);
        css("style","pointer");
        bind("click",{id:"PanUp"},handleToolClick);
    }

    with($(divPanLeft))
    {
        css("position","absolute");
        css("left",offsetLeft);
        css("top",offsetTop + 20);
        css("style","pointer");
        bind("click",{id:"PanLeft"},handleToolClick);
    }

    with($(divLastView))
    {
        css("position","absolute");
        css("left",offsetLeft + 20);
        css("top",offsetTop + 20);
        css("style","pointer");
        bind("click",{id:"LastView"},handleToolClick);
    }

    with($(divPanRight))
    {
        css("position","absolute");
        css("left",offsetLeft + 40);
        css("top",offsetTop + 20);
        css("style","pointer");
        bind("click",{id:"PanRight"},handleToolClick);
    }

    with($(divPanDown))
    {
        css("position","absolute");
        css("left",offsetLeft + 20);
        css("top",offsetTop + 40);
        css("style","pointer");
        bind("click",{id:"PanDown"},handleToolClick);
    }

    with($(divZoomIn))
    {
        css("position","absolute");
        css("left",offsetLeft + 20);
        css("top",offsetTop + 60);
        css("style","pointer");
        bind("click",{id:"ZoomIn"},handleToolClick);
    }

    with($(divZoomOut))
    {
        css("position","absolute");
        css("left",offsetLeft + 20);
        css("top",offsetTop + 80);
        css("style","pointer");
        bind("click",{id:"ZoomOut"},handleToolClick);
    }

    
    with($("#divTools"))
    {
        empty();
        append(divPanUp);
        append(divPanLeft);
        append(divLastView);
        append(divPanRight);
        append(divPanDown);
        append(divZoomIn);
        append(divZoomOut);
    }
}



//提取植被指数Div
/*
× 根据用户登录所属的区域，添加省级和（或）县级行政区选择框，行政区的名称由数据库实时查询得到；
× 用户选择行政区后，然后选择年份，然后列出用户可以选择的影像名称列表；
× 用户选择某影像，然后计算该影像对应样点的植被指数（其中样点数据也需要实时从数据库中读取）
   10月31日修改：增加方法的参数
   modelType参数：判断当前模块的类型，grow为作物长势监测模块,rs为作物遥感单产估算模块,quality为品质趋势预热
*/
function createRSIndexDiv(modelType)
{
    var divSelections = document.createElement("div");
    var divImages =  document.createElement("div");
    var divContent = document.createElement("div");
    var divCustomIndex = document.createElement("div");
    
    
    
    var txtProvince = document.createTextNode("省（市、自治区）");
    var txtCounty = document.createTextNode("县（市、区）");
    var txtYear = document.createTextNode("年");
    
    var sltProvince = document.createElement("select");
    sltProvince.id = "sltProvince";
    var sltCounty = document.createElement("select");
    sltCounty.id = "sltCounty";
    var sltYear = document.createElement("select");
    sltYear.id = "sltYear";
    
    var thisDate = new Date();
    var thisYear = thisDate.getFullYear();
    for(var i = 0; i < 10; i++)
    {
        var yearOption = document.createElement("option");
        yearOption.value = thisYear - i;
        yearOption.text = thisYear - i;
        sltYear.options.add(yearOption);
    }
    
//    var ProvinceOptionText;
//    var ProvinceOptionValue;
//    
//    var countyOptionText;
//    var countyOptionValue;
    
    if (parseInt(USER_DISTRICT_ID) == 0 )
    {
        var ProvinceOptionText = new Array("北京","河北","吉林","黑龙江","江苏","山东","河南","湖南","浙江","新疆");
        var ProvinceOptionValue = new Array("1","5","9","10","11","16","17","19","12","31");
        var ProvinceOptions  = createOptions(ProvinceOptionValue,ProvinceOptionText);
        for(var i = 0; i < ProvinceOptionText.length; i++)
        {
            sltProvince.options.add(ProvinceOptions[i]);
        }
        fillCountySelect();
        $(sltProvince).bind("change",fillCountySelect);
    }
    else
    {
        if (parseInt(USER_DISTRICT_ID) == 1 )
        {
            
            var countyOptionText = new Array("全省（市、区）","大兴","通州","顺义","昌平","密云","平谷","怀柔","延庆","房山","丰台","门头沟","石景山","海淀","朝阳","中心四城区");
            var countyOptionValue = new Array("1","74","71","72","73","78","76","75","77","70","66","69","67","68","65","61");
            var countyOptions  = createOptions(countyOptionValue,countyOptionText);
            for(var i = 0; i < countyOptions.length; i++)
            {
                    sltCounty.options.add(countyOptions[i]);
            }            
        }
        else if(parseInt(USER_DISTRICT_ID) < 50)
        {
            //待修改，采用异步方式获得所有子节点及自己
            strUrl = "Services/getDistrictList.aspx";
            $.get(strUrl,{DISTID:USER_DISTRICT_ID,
                          TEMP:Math.random()
                          },
                          function(data){
                              var xmlDocument = data.documentElement;
                              var nDistricts = xmlDocument.childNodes.length;
                              var countyOptionText = new Array();
                              var countyOptionValue = new Array();
                              for(var i = 0; i < nDistricts; i++)
                              {
                                countyOptionText[i] = xmlDocument.childNodes[i].attributes[1].nodeValue;
                                countyOptionValue[i] = xmlDocument.childNodes[i].attributes[0].nodeValue;
                              }
                              var countyOptions  = createOptions(countyOptionValue,countyOptionText);
                              for(var i = 0; i < countyOptions.length; i++)
                              {
                                  sltCounty.options.add(countyOptions[i]);
                              }
                          });
        
        }
        else
        {
            var countyOptionText = new Array(USER_DISTRICT_NAME);
            var countyOptionValue = new Array(USER_DISTRICT_ID);
            var countyOptions  = createOptions(countyOptionValue,countyOptionText);
            for(var i = 0; i < countyOptions.length; i++)
            {
                    sltCounty.options.add(countyOptions[i]);
            }            
        }
    }
    

    
    var btnGetImageList = document.createElement("input");
    btnGetImageList.type = "button";
    btnGetImageList.value = "查询影像列表";
    
    //为获取遥感影像列表button绑定点击时间
    $(btnGetImageList).bind("click",function(){
        var selectedLocation = sltCounty.value;
        var selectedyear = sltYear.value;

        var strURL = "services/getImageList.aspx";
        
        //执行按钮点击后的事件，查找image list并生成元素
        $.get(strURL,{LOC:selectedLocation,YEAR:selectedyear,tmp:Math.random()},function(data){
            var xmlDocument = data.documentElement;
            
            var nImages = xmlDocument.childNodes.length;
            if (nImages == 0) 
            {
                $(divImages).empty();
                alert("没有符合您要求的影像数据！");
                return;
            }
            var imageId = new Array();
            var imageName = new Array();
            var BrowserType = getBrowserType();
            if(BrowserType == "MSIE")
            {
                for (var i = 0; i < nImages; i++)
                {
                    imageId[i] = xmlDocument.childNodes[i].attributes[0].nodeValue;
                    imageName[i] = xmlDocument.childNodes[i].attributes[1].nodeValue;
                }
            }
            else
            {
                for (var i = 0; i < (nImages -1)/2; i++)
                {
                    imageId[i] = xmlDocument.childNodes[i * 2 + 1].attributes[0].nodeValue;
                    imageName[i] = xmlDocument.childNodes[i * 2 + 1].attributes[1].nodeValue;
                }
            }
            var sltImageList = document.createElement("select");
            sltImageList.id = "ImageListSelect";

            var ImageOptions = createOptions(imageId,imageName);
            for (var i = 0; i < ImageOptions.length; i++)
            {
                sltImageList.options.add(ImageOptions[i]);
            }
            
            //====================================================
            //YangXD  
            //2008.12.09
            //增加样点block大小选择
            var sltBlockSizeList = document.createElement("select");
            sltBlockSizeList.id = "BlockSizeSelect";
            var blockSizeOptionsId = new Array("size1","size3","size5");
            var blockSizeOptionsName = new Array("1 × 1","3 × 3","5 × 5");

            var BlockSizeOptions = createOptions(blockSizeOptionsId,blockSizeOptionsName);
            for (var i = 0; i < BlockSizeOptions.length; i++)
            {
                sltBlockSizeList.options.add(BlockSizeOptions[i]);
            }
            //===================================================
            
            //10-31日添加判断条件modelType
            if(modelType=="grow")
            {
                var btnOpenSamplePoints = document.createElement("input");
                btnOpenSamplePoints.type = "button";
                btnOpenSamplePoints.value = "查看样点文件";
                //$(btnOpenSamplePoints).bind("click",{fileName:$(sltImageList).val()},loadSamplePointsTable); 
                
                $(btnOpenSamplePoints).bind("click",loadSamplePointsTable);            

                var btnGetIndex = document.createElement("input");
                btnGetIndex.type = "button";
                btnGetIndex.value = "提取植被指数";
                //$(btnGetIndex).bind("click",{fileName:$(sltImageList).val()},calculateRSIndex);
                $(btnGetIndex).bind("click",calculateRSIndex);
                
                //==========================================================
                //YangXD
                //2008.12.09
                //增加自定义植被指数计算功能
                var btnSetCustomIndex = document.createElement("input");
                btnSetCustomIndex.type = "button";
                btnSetCustomIndex.value = "设置自定义植被指数";
                //$(btnGetIndex).bind("click",{fileName:$(sltImageList).val()},calculateRSIndex);
                $(btnSetCustomIndex).bind("click",function(){
                    
                    $(btnGetIndex).attr("disabled",true)
                    
                    var txtCustomIndexFormula = document.createTextNode("请输入自定义植被指数表达式（格式参考ENVI的band math要求）：");
                    var CustomIndexTextBoxName = new Array("CustomIndexText");
                    var CustomIndexTextBox = createTexts(CustomIndexTextBoxName);
                    $(CustomIndexTextBox).width(330);
                    
                    var txtBandlist = document.createTextNode("请输入波段列表（以,分割，如4,3,2表示使用了4、3、2三个波段）：");
                    var BandlistTextBoxName = new Array("BandListText");
                    var BandlistTextBox = createTexts(BandlistTextBoxName);
                    $(BandlistTextBox).width(330);
                    
                    
                    var btnGetCustomIndex = document.createElement("input");
                    btnGetCustomIndex.type = "button";
                    btnGetCustomIndex.value = "提取植被指数";
                    $(btnGetCustomIndex).bind("click",calculateCustomRSIndex); 
                    
                    var btnCancelCustomIndex = document.createElement("input");
                    btnCancelCustomIndex.type = "button";
                    btnCancelCustomIndex.value = "放弃提取自定义植被指数";
                    $(btnCancelCustomIndex).bind("click",function(){
                        $(btnGetIndex).attr("disabled",false)
                        with($(divCustomIndex)) {
                            css("margin-top","0px");
                            css("border","solid 0px black")
                            empty();
                        }
                    });   
                    
                with($(divCustomIndex)) {
                    css("margin-top","10px");
                    css("border","solid 1px black")
                    empty();
                    append(txtCustomIndexFormula);
                    append("<br/>");
                    append(CustomIndexTextBox);
                    append("<br/>");

                    append(txtBandlist);
                    append("<br/>");
                    append(BandlistTextBox);
                    append("<br/>");

                    append(btnGetCustomIndex);
                    append(btnCancelCustomIndex);
                }          
            
            });
            //================================================================    
                            
            }
            if(modelType=="rs")
            {
                var btnOpenSamplePoints = document.createElement("input");
                btnOpenSamplePoints.type = "button";
                btnOpenSamplePoints.value = "查看样点文件";
                //11-3日修改
                $(btnOpenSamplePoints).bind("click",loadSamplePointsAndYield);            

                var btnGetIndex = document.createElement("input");
                btnGetIndex.type = "button";
                btnGetIndex.value = "提取植被指数";
                //11-3日修改
                $(btnGetIndex).bind("click",calculateRSIndexForYield);
            }
            if(modelType=="quality")
            {
                var btnOpenSamplePoints = document.createElement("input");
                btnOpenSamplePoints.type = "button";
                btnOpenSamplePoints.value = "查看样点文件";
                //11-10日修改
                $(btnOpenSamplePoints).bind("click",loadSamplePointsAndQuality);            

                var btnGetIndex = document.createElement("input");
                btnGetIndex.type = "button";
                btnGetIndex.value = "提取植被指数";
                //11-10日修改
                $(btnGetIndex).bind("click",calculateRSIndexForQuality);
            }
            if(modelType=="Rsquality")//11-19日添加
            {
                var btnOpenSamplePoints = document.createElement("input");
                btnOpenSamplePoints.type = "button";
                btnOpenSamplePoints.value = "查看样点文件";                
                $(btnOpenSamplePoints).bind("click",loadSamplePointsAndRSQuality); 
                
                var btnGetIndex = document.createElement("input");
                btnGetIndex.type = "button";
                btnGetIndex.value = "提取植被指数";                
                $(btnGetIndex).bind("click",calculateRSIndexForRSQuality);//品质监测中的提取植被指数要修改11-21日
            }
            //10-31日添加判断条件modelType
            with($(divImages)){
//                empty();
//                append(sltImageList);
//                append("<br/>");
//                append(btnOpenSamplePoints);
//                append(btnGetIndex);

                //=============================================
                //YangXD
                //2008.12.09
                //调整页面布局

                css("margin-top","10px");
                css("border","solid 1px black")                
                empty();
                append(sltImageList);
                append("<br/>");
                append(btnOpenSamplePoints);
                append("<br/>");
                append(sltBlockSizeList);
                append(btnGetIndex);
                append(btnSetCustomIndex)
                append(divCustomIndex)
                
                //=============================================

            }

        });
        $("#forDatacache").data("calculateType",modelType);//存入当前操作的类型，以备在创建模型时判断
    });
    
    with($(divSelections)){
        if(parseInt(USER_DISTRICT_ID)==0)
        {
            append(sltProvince);
            append(txtProvince);
        }
        append(sltCounty);
        append(txtCounty);
        append("<br/>");
        append(sltYear);
        append(txtYear);
        append("<br/>");
        append(btnGetImageList);
        
    }
    
    with($(divContent)){
//        css("min-height",180);
        append(divSelections);
        append(divImages);
//        height(330);
//        css("overflow","scroll");
    }
    
    return divContent;
}  


//参数关联Div
function createParamRelateDiv()
{
    var divContent = document.createElement("div");

    //定义表格的列名称
    var txtAgriTitle = document.createTextNode("农学参数");
    var txtRSIndexTitle = document.createTextNode("植被指数");
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义农学参数名称列表
    var txtAgriArray = new Array(   "植株总干重(PLANTGDW)",
                                    "总叶干重(LEAFGDW)",
                                    "叶面积指数（LAI）",
                                    "叶片含水量(MCL)",
                                    "单位土地面积含水量(EWT)",
                                    "叶片含氮量(NCL)",
                                    "单位土地面积含氮量(CND)",
                                    "鲜叶叶绿素a含量(CHL_A)",
                                    "叶绿素a密度(DEN_CHLA)",
                                    "鲜叶叶绿素总含量(CHL_AB)",
                                    "总叶绿素密度(DEN_CHL)",
                                    "鲜叶类胡萝卜素含量(CAROC)",
                                    "类胡萝卜素密度(DEN_CARO)");
    //创建农学参数的textnode数组                                
    var txtNodeAgriArray = createTextNode(txtAgriArray);                                
    
    //定义农学参数的CheckBox ID列表
    var txtChkAgriArray = new Array("chkPLANTGDW",
                                    "chkLEAFGDW",
                                    "chkLAI",
                                    "chkMCL",
                                    "chkEWT",
                                    "chkNCL",
                                    "chkCND",
                                    "chkCHL_A",
                                    "chkDEN_CHLA",
                                    "chkCHL_AB",
                                    "chkDEN_CHL",
                                    "chkCAROC",
                                    "chkDEN_CARO");
    
    //定义农学参数的CheckBox数组                                
    var chkAgriArray = createCheckboxs(txtChkAgriArray); 
    
    //将名称与checkbox连接成span元素
    var spanAgriArray = new Array();
    for(var i = 0; i < txtChkAgriArray.length; i++)
    {
        spanAgriArray[i] = document.createElement("span");
        spanAgriArray[i].appendChild(chkAgriArray[i]);
        spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    
                                   
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义植被指数名称列表
    var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2","CustomIndex","","","","");
    
    //创建植被指数的textnode数组       
    var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
    
    //定义植被指数的CheckBox ID列表
    var txtChkRSIndexArray = new Array("chkNDWI", "chkNDWI2", "chkNDVI", "chkNRI",	"chkNSI", "chkWI", "chkG_SWIR", "chkG_SWIR2", "chkCustomIndex","","","","");
    
    //定义植被指数的CheckBox数组                                
    var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
    
    //将名称与checkbox连接成span元素
    var spanRSIndexArray = new Array();
    for(var i = 0; i < txtRSIndexArray.length; i++)
    {
        spanRSIndexArray[i] = document.createElement("span");
        spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
        spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////

    
    //创建绘制地图的button元素
    var btnCalcuRxy = document.createElement("input");
    btnCalcuRxy.type = "button";
    btnCalcuRxy.value = "计算相关系数";
    $(btnCalcuRxy).bind("click",function(){
        var selectedAgriParams = "";
        var selectedRSIndex = "";
        for(var i = 0; i < chkRSIndexArray.length; i++)
        {
            if(chkAgriArray[i].checked == true)
            {
                selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
            }
            if(chkRSIndexArray[i].checked == true)
            {
                selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
            }

        }
        if(selectedAgriParams.length == 0) {alert("您没有选择农学参数，请您先选择至少一项农学参数！");return;}
        if(selectedRSIndex.length == 0) {alert("您没有选择植被指数，请您先选择至少一项植被指数！");return;}
        selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
        selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
        
        var imageId = $("#ImageListSelect").val();
        if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
        
        calculateRelatedCoefficient(selectedAgriParams,selectedRSIndex,"grow");//11-4日，此方法增加参数，以确定要显示的列头
    
    });
    

    //将上面生成的元素组织成表格形式
    var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle);
    var paramTableValue = new Array(spanAgriArray,spanRSIndexArray);
    var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
    
    //将表格和button添加到div
    with($(divContent)){
        append(paramTable);
        append(btnCalcuRxy);
//        css("min-height",180);
//        height(330);
//        css("overflow","scroll");
    }

    return divContent;

}

//单产模块关联参数div***************************************************************************************************
function createParamRelateDivForYeild()
{
    var divContent = document.createElement("div");

    //定义表格的列名称
    var txtAgriTitle = document.createTextNode("单          产");
    //txtAgriTitle.width=100;
    var txtRSIndexTitle = document.createTextNode(" 植被指数 ");
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义农学参数名称列表
    var txtAgriArray = new Array("单    产","","","","","","","");
    //创建农学参数的textnode数组                                
    var txtNodeAgriArray = createTextNode(txtAgriArray);                                
    
    //定义农学参数的CheckBox ID列表
    var txtChkAgriArray = new Array("chkYEILD","","","","","","","");
    
    //定义农学参数的CheckBox数组                                
    var chkAgriArray = createCheckboxs(txtChkAgriArray); 
    
    //将名称与checkbox连接成span元素
    var spanAgriArray = new Array();
    for(var i = 0; i < txtChkAgriArray.length; i++)
    {
        spanAgriArray[i] = document.createElement("span");
        
        spanAgriArray[i].appendChild(chkAgriArray[i]);
        txtNodeAgriArray[i].nodeValue+="";
        spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
        
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    
                                   
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义植被指数名称列表
    var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2");
    
    //创建植被指数的textnode数组       
    var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
    
    //定义植被指数的CheckBox ID列表
    var txtChkRSIndexArray = new Array("chkNDWI", "chkNDWI2", "chkNDVI", "chkNRI",	"chkNSI", "chkWI", "chkG_SWIR", "chkG_SWIR2");
    
    //定义植被指数的CheckBox数组                                
    var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
    
    //将名称与checkbox连接成span元素
    var spanRSIndexArray = new Array();
    for(var i = 0; i < txtRSIndexArray.length; i++)
    {
        spanRSIndexArray[i] = document.createElement("span");
        spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
        spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////

    
    //创建绘制地图的button元素
    var btnCalcuRxy = document.createElement("input");
    btnCalcuRxy.type = "button";
    btnCalcuRxy.value = "计算相关系数";
    $(btnCalcuRxy).bind("click",function(){
        var selectedAgriParams = "";
        var selectedRSIndex = "";
        for(var i = 0; i < chkRSIndexArray.length; i++)
        {
            if(chkAgriArray[i].checked == true)
            {
                selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
            }
            if(chkRSIndexArray[i].checked == true)
            {
                selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
            }

        }
        if(selectedAgriParams.length == 0) {alert("您没有选择单产");return;}
        if(selectedRSIndex.length == 0) {alert("您没有选择植被指数，请您先选择至少一项植被指数！");return;}
        selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
        selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
        
        var imageId = $("#ImageListSelect").val();
        if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
        
        calculateRelatedCoefficient(selectedAgriParams,selectedRSIndex,"rs");//11-4日，此方法增加参数，以确定要显示的列头
    
    });
    

    //将上面生成的元素组织成表格形式
    var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle);
    var paramTableValue = new Array(spanAgriArray,spanRSIndexArray);
    var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
    
    //将表格和button添加到div
    with($(divContent)){
        append(paramTable);
        append(btnCalcuRxy);
        
    }
    
    return divContent;

}
//单产模块关联参数div***************************************************************************************************


//品质趋势预报相关指数计算,11-11日
function createParamRelateForQualityDiv()
{
    var divContent =document.createElement("div");
    //定义各种指数的表格列名
    //var txtQualityTitle=document.createTextNode("农学参数");
    var txtAgriTitle=document.createTextNode("农学参数");
    var txtRSIndexTitle=document.createTextNode("植被指数");
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义品质指标名称列表
    var txtQualityArray=new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2");
    //创建品质指标的txtnode数组
    var txtNodeQualityArray=createTextNode(txtQualityArray);
    //定义品质指标的checkbox ID列表
    var txtChkQualityArray=new Array("chkNDWI", "chkNDWI2", "chkNDVI", "chkNRI",	"chkNSI", "chkWI", "chkG_SWIR", "chkG_SWIR2");
    //定义品质指标的checkBox数组
    var chkQualityArray=createCheckboxs(txtChkQualityArray);
    //将名称与checkbox连接成span元素
    var spanQualityArray=new Array();
    for(var i=0;i<txtChkQualityArray.length;i++)
    {
        spanQualityArray[i]=document.createElement("span");
        spanQualityArray[i].appendChild(chkQualityArray[i]);
        spanQualityArray[i].appendChild(txtNodeQualityArray[i]);
    }
    
    //定义农学参数名称列表
     var txtAgriArray = new Array(  
                                    "叶片含氮量(NCL)",
                                    "单位土地面积含氮量(CND)",
                                    "鲜叶叶绿素a含量(CHL_A)",
                                    "叶绿素a密度(DEN_CHLA)",
                                    "鲜叶叶绿素总含量(CHL_AB)",
                                    "总叶绿素密度(DEN_CHL)",
                                    "",
                                    ""
                                    );
    //创建农学参数的textnode数组                                
    var txtNodeAgriArray = createTextNode(txtAgriArray);
    //定义农学参数的CheckBox ID列表
    var txtChkAgriArray = new Array("chkNCL",
                                    "chkCND",
                                    "chkCHL_A",
                                    "chkDEN_CHLA",
                                    "chkCHL_AB",
                                    "chkDEN_CHL",
                                    "",
                                    ""
                                    ); 
   //定义农学参数的CheckBox数组                                
    var chkAgriArray = createCheckboxs(txtChkAgriArray); 
    
    //将名称与checkbox连接成span元素
    var spanAgriArray = new Array();
    for(var i = 0; i < txtChkAgriArray.length; i++)
    {
        spanAgriArray[i] = document.createElement("span");
        spanAgriArray[i].appendChild(chkAgriArray[i]);
        spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////

    
    //创建绘制地图的button元素
    var btnCalcuRxy = document.createElement("input");
    btnCalcuRxy.type = "button";
    btnCalcuRxy.value = "计算相关系数";
    $(btnCalcuRxy).bind("click",function(){
        var selectedAgriParams = "";
        
        var selectcdQuality="";
        for(var i = 0; i < chkAgriArray.length; i++)
        {
            if(chkAgriArray[i].checked == true)
            {
                selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
            }
            
            if(chkQualityArray[i].checked==true)
            {
                selectcdQuality+=chkQualityArray[i].id.substring(3)+",";
            }
        }
        if(selectedAgriParams.length == 0) {alert("您没有选择农学参数，请您先选择至少一项农学参数！");return;}
        
        if(selectcdQuality.length==0){alert("您还没有选择品质指标，请您先选择至少一项品质指标！");return}
        selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
        
        selectcdQuality=selectcdQuality.substring(0,selectcdQuality.length-1);//选择的品质指标11-11日添加
        
        var imageId = $("#ImageListSelect").val();
        if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
        
        
        
        
        
        calculateRelatedCoefficient(selectedAgriParams,selectcdQuality,"quality");
    
    });
    

    //将上面生成的元素组织成表格形式
    var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle);
    var paramTableValue = new Array(spanAgriArray,spanQualityArray);
    var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
    
    //将表格和button添加到div
    with($(divContent)){
        append(paramTable);
        append(btnCalcuRxy);
//        css("min-height",180);
//        height(330);
//        css("overflow","scroll");
    }

    return divContent;

}

//品质趋势预报相关指数计算,11-19日
function createParamRelateForRSQualityDiv()
{
    var divContent =document.createElement("div");
    //定义各种指数的表格列名
    var txtQualityTitle=document.createTextNode("品质指数");
    var txtRSIndexTitle=document.createTextNode("植被指数");
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义品质指标名称列表
    var txtQualityArray=new Array(
                                    "粗蛋白质含量(CRUDEPP)",
                                    "湿面筋含量(WETGP)",
                                    "稳定时间(SETTIME)",
                                    "子粒含氮量(NCONTENT)",
                                    "",
                                    "",
                                    "",
                                    ""
                                    
    );
    //创建品质指标的txtnode数组
    var txtNodeQualityArray=createTextNode(txtQualityArray);
    //定义品质指标的checkbox ID列表
    var txtChkQualityArray=new Array(
                                    "chkCRUDEPP",
                                    "chkWETGP",
                                    "chkSETTIME",
                                    "chkNCONTENT",
                                    "",
                                    "",
                                    "",
                                    ""
                                    
    );
    //定义品质指标的checkBox数组
    var chkQualityArray=createCheckboxs(txtChkQualityArray);
    //将名称与checkbox连接成span元素
    var spanQualityArray=new Array();
    for(var i=0;i<txtChkQualityArray.length;i++)
    {
        spanQualityArray[i]=document.createElement("span");
        spanQualityArray[i].appendChild(chkQualityArray[i]);
        spanQualityArray[i].appendChild(txtNodeQualityArray[i]);
    }
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义植被指数名称列表
    var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2");
    
    //创建植被指数的textnode数组       
    var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
    
    //定义植被指数的CheckBox ID列表
    var txtChkRSIndexArray = new Array("chkNDWI", "chkNDWI2", "chkNDVI", "chkNRI",	"chkNSI", "chkWI", "chkG_SWIR", "chkG_SWIR2");
    
    //定义植被指数的CheckBox数组                                
    var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
    
    //将名称与checkbox连接成span元素
    var spanRSIndexArray = new Array();
    for(var i = 0; i < txtRSIndexArray.length; i++)
    {
        spanRSIndexArray[i] = document.createElement("span");
        spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
        spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////
    var btnCalcuRxy = document.createElement("input");
    btnCalcuRxy.type = "button";
    btnCalcuRxy.value = "计算相关系数";
    $(btnCalcuRxy).bind("click",function(){
        var selectedRSIndex = "";               
        var selectcdQuality="";
        for(var i = 0; i < chkRSIndexArray.length; i++)
        {
            if(chkRSIndexArray[i].checked == true)
            {
                selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
            }
            
            if(chkQualityArray[i].checked==true)
            {
                selectcdQuality+=chkQualityArray[i].id.substring(3)+",";
            }
        }
        if(selectedRSIndex.length == 0) {alert("您没有选择农学参数，请您先选择至少一项植被指数！");return;}
        
        if(selectcdQuality.length==0){alert("您还没有选择品质指标，请您先选择至少一项品质指标！");return}
        selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
        
        selectcdQuality=selectcdQuality.substring(0,selectcdQuality.length-1);//
        
        var imageId = $("#ImageListSelect").val();
        if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
        calculateRelatedCoefficient(selectedRSIndex,selectcdQuality,"Rsquality");
    
    });
    

    //将上面生成的元素组织成表格形式
    var paramTableTitle = new Array(txtRSIndexTitle,txtQualityTitle);
    var paramTableValue = new Array(spanRSIndexArray,spanQualityArray);
    var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
    
    //将表格和button添加到div
    with($(divContent)){
        append(paramTable);
        append(btnCalcuRxy);
//        css("min-height",180);
//        height(330);
//        css("overflow","scroll");
    }

    return divContent;


}


//模型选择Div
function createModelSelectDiv()
{
    var divContent = document.createElement("div");

    var txtModelName = document.createTextNode("模型名称");
    var txtModelEquation = document.createTextNode("模型方程");
    var txtModelR_Squared =  document.createTextNode("拟合优度");
    var txtModelSelect =  document.createTextNode("选择模型");
    
    var txtLine = document.createTextNode("线性模型");
    var txtExp = document.createTextNode("指数模型");
    var txtLn = document.createTextNode("对数模型");
    
//    var txtChoice1 = document.createTextNode("选择");
//    var txtChoice2 = document.createTextNode("选择");
//    var txtChoice3 = document.createTextNode("选择");
    
    var txtTitleNames = new Array(txtLine,txtExp,txtLn);

    //创建模型选择的radio元素
    var modelRadioNameArray = new Array("radioLine","radioExp","radioLn");
    
    var modelRradioArray = new Array();
    modelRradioArray = createRadios(modelRadioNameArray,radioCheckModel);
    
//    //创建参数选择checkbox
//    var checkboxNameArray = new Array("chkLAI","chkBiomass","chkNDVI","chkNDWI");
//    var checkboxArray = new Array();
//    checkboxArray = createCheckboxs(checkboxNameArray);

    //空文本串
    var txtBlank = document.createTextNode("");

    //记录模型方程的文本框
    var txtTextNameArray = new Array("txtLine","txtExp","txtLn");
    var txtTextArray = new Array();
    txtTextArray = createTexts(txtTextNameArray);
    
    //记录拟合优度的文本框
    txtTextNameArray = new Array("txtLineR","txtExpR","txtLnR");
    var txtRArray = new Array();
    txtRArray = createTexts(txtTextNameArray);
    
    for(var i = 0; i < txtTextArray.length; i++)
    {
//        txtTextArray[i].disabled ="disabled";
//        txtRArray[i].disabled ="disabled";
        $(txtTextArray[i]).bind("change",{elem:$(txtTextArray[i]).attr("id")},function(event){
            alert("该处仅用于显示计算结果，不能接受任何数据输入！");
            //$(txtTextArray[i]).val("");
            eval($('#' + event.data.elem)).val("");
        });
        
        $(txtRArray[i]).bind("change",{elem:$(txtRArray[i]).attr("id")},function(event){
            alert("该处仅用于显示计算结果，不能接受任何数据输入！");
            //$(txtRArray[i]).val("");
            eval($('#' + event.data.elem)).val("");
        });
    }
    
    
    //创建计算模型的button元素
    var calcuButtonNameArray = new Array("计算");
    calcuButtonArray = createButtons(calcuButtonNameArray,"");
    $(calcuButtonArray).bind("click",resolveModelParam);
    
//    var calcuButtonNameArray = new Array("计算","计算","计算");
//    var calcuButtonArray = new Array();
//    calcuButtonArray = createButtons(calcuButtonNameArray,"");
//    for(i = 0;i < calcuButtonArray.length; i++)
//    {
//        $(calcuButtonArray[i]).bind("click",{id:i},resolveModelParam);
//    }

    //div content3的元素表格
    var modelTableTitle = new Array(txtModelName,txtModelEquation,txtModelR_Squared,txtModelSelect);
//    var modelTableValue1 = new Array(txtLine,calcuButtonArray[0],txtTextArray[0],modelRradioArray[0]);
//    var modelTableValue2 = new Array(txtExp,calcuButtonArray[1],txtTextArray[1],modelRradioArray[1]);
//    var modelTableValue3 = new Array(txtLn,calcuButtonArray[2],txtTextArray[2],modelRradioArray[2]);
//    var modelTableValue4 = new Array(txtBlank,previousButtonArray[1],txtBlank,nextButtonArray[2]);


//    var modelTableValueAll = new Array(modelTableValue1,modelTableValue2,modelTableValue3);
    var modelTableValueAll = new Array(txtTitleNames,txtTextArray,txtRArray,modelRradioArray);
    var modelTable = new DataTable(modelTableTitle,modelTableValueAll,2);


    with($(divContent))
    {
        append(modelTable);
        append(calcuButtonArray);
//        css("min-height",180);
//        append("<br/><br/><br/><br/>");
//        height(330);
//        css("overflow","scroll");
    }
    
    return divContent;

}

//长势绘图Div
function createDrawGrowingGraphDiv()
{
    var divGraduations = document.createElement("div");
//    divGraduations.id = "Graduations";
    var divButtons = document.createElement("div");
    var divContent = document.createElement("div");
 
    var txtClassNumber = document.createElement("input");
    txtClassNumber.type = "text";
    txtClassNumber.width = "72";
    txtClassNumber.id = "classNumber";
    
    //设置一个隐藏文本框来记录分级设置的级别数
    var hiddenTextNumber = document.createElement("input");
    hiddenTextNumber.id = "GraduationNumber";
    hiddenTextNumber.type = "hidden";
    hiddenTextNumber.value = 0;

    
    //创建绘制地图的button元素
    var btnClassify = document.createElement("input");
    btnClassify.type = "button";
    btnClassify.value = "设置分级刻度";
//    btnClassify.attachEvent("onclick",function(){
    $(btnClassify).bind("click",{desc:arguments[0]},function(event){
        //待添加处理用户权限的处理...........////////////////////////////////////////////////////////////////////////////
        var classNumber = txtClassNumber.value;
        if(classNumber.length == 0 || classNumber == "0") 
        {
            $(divGraduations).empty();
            $(txtClassNumber).val("");

            //alert("请在左侧文本框中填写分级刻度数！");
            return;
        }
        else if(classNumber == "1")
        {
            alert("分级刻度数至少应该大于等于2！");
            return;
        }
        var txtGraduationValueNames = new Array();
        var txtGraduationLabelNames = new Array();
        var txtGraduationColorNames = new Array();
        var baseText1 = "Graduation";
        var baseText2 = "Label";
        var baseText3 = "Color"
        for(var i = 0;i < classNumber;i++)
        {
            //txtGraduationNames[i] = baseText1 + i;
            txtGraduationValueNames[i] = baseText1 + i;
            txtGraduationLabelNames[i] = baseText2 + i;
            txtGraduationColorNames[i] = baseText3 + i;
        }
        
        //var txtGraduations = new Array();
        //txtGraduations =createTextNode(txtGraduationNames)
        
        var txtGraduationValues = new Array();
        txtGraduationValues = createTexts(txtGraduationValueNames);
        
        var txtGraduationLabels = new Array();
        txtGraduationLabels = createTexts(txtGraduationLabelNames);
        
        var txtGraduationColors = new Array();
        txtGraduationColors = createTexts(txtGraduationColorNames);
        
        for(var i = 0; i < txtGraduationValues.length; i++)
        {
            $(txtGraduationValues[i]).width(135);
            $(txtGraduationLabels[i]).width(135);
            $(txtGraduationColors[i]).width(80);
        }
//        txtGraduationLabels[0].style.visibility = "hidden";
//        txtGraduationColors[0].style.visibility = "hidden";
               
        
        var ColorIndex = 1;
        for(var i = 0; i < txtGraduationColors.length; i++)
        {
            $(txtGraduationColors[i]).bind("click",{id:i},function(event){
                ColorIndex = event.data.id;
            });
            
            $(txtGraduationColors[i]).ColorPicker({
	            onSubmit: function(hsb, hex, rgb) {
		            //$('#Label' + i).val(hex);
		            //alert(labelIndex);
		            eval($('#Color' + ColorIndex)).val(hex);
		            
	            },
	            onBeforeShow: function () {
		            $(this).ColorPickerSetColor(this.value);
	            }
            });
//            .bind('keyup', function(){
//	            $(this).ColorPickerSetColor(this.value);
//            })
        }
        
        //var tableTitleString = new Array("农学参数刻度(数字)","长势状况描述（文字）","颜色设置");
        var tableTitleString="";
        if(arguments.length>0)
        { 
            var my_desc=event.data.desc;  
            if(my_desc=="长势分级")
            {
                tableTitleString = new Array("农学参数刻度(数字)","长势状况描述（文字）","颜色设置");
            } 
            else if(my_desc=="品质预报分级")
            {
                tableTitleString = new Array("农学参数刻度(数字)","品质预报描述（文字）","颜色设置");
            }  
            else if(my_desc=="品质遥感监测")
            {
                tableTitleString = new Array("农学参数刻度(数字)","品质监测描述（文字）","颜色设置");
            }    
            else
            {
                tableTitleString = new Array("农学参数刻度(数字)","长势状况描述（文字）","颜色设置");
            }
        }else
        {
            tableTitleString = new Array("农学参数刻度(数字)","长势状况描述（文字）","颜色设置");
        }
        
        var tableTitles = createTextNode(tableTitleString);
//*************************************************************************************************   12-9日修改    
//        var tableValue = new Array(txtGraduationValues,txtGraduationLabels,txtGraduationColors);     
//        var table = new DataTable(tableTitles,tableValue, 2);
        //定义设置默认选项的title列表
        var txtDefaultControl = new Array(" 默认值", " 默认值", " 默认值");
        
        //创建默认选项的textnode数组       
        var txtDefaultControlArray = createTextNode(txtDefaultControl);                                

        //定义设置默认选项的CheckBox ID列表
        var txtChkDefaultControlArray = new Array("defGraduations", "defLabels", "defColors");
        
        //定义设置默认选项的CheckBox数组                                
        var chkDefaultControlArray = createCheckboxs(txtChkDefaultControlArray); 
        
        for(var i = 0; i < chkDefaultControlArray.length; i++)
        {
            $(chkDefaultControlArray[i]).bind("click",function(){
                if($("#defGraduations").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",false);// = false;
                    }
                }
                
                if($("#defLabels").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",false);// = false;
                    }
                }
                if($("#defColors").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",false);// = false;
                    }
                }

            });        
        }
        
        var tableTitles2 = new Array();
        for (var i = 0; i < 3; i++)
        {
            tableTitles2[i] = document.createElement("span");
            with($(tableTitles2[i]))
            {
                append(tableTitles[i]);
                append("<br/>");

                append(chkDefaultControlArray[i]);
                append(txtDefaultControlArray[i]);
            }
            //tableTitles2[i].style.width = "120px";
        }   
        
        
             
        var tableValue = new Array(txtGraduationValues,txtGraduationLabels,txtGraduationColors);
        
        var table = new DataTable(tableTitles2,tableValue, 2);

//************************************************************************************************* <---12-9日修改  

//        var table = new DataTable(txtGraduations,tableValue, 1);
//        $("#table").attr("id","Graduations");

        hiddenTextNumber.value = classNumber;
        
        $(divGraduations).empty();
        divGraduations.appendChild(table);
        divGraduations.appendChild(hiddenTextNumber);
    });


    //创建绘制地图的button元素
    var btnDraw = document.createElement("input");
    btnDraw.type = "button";
    btnDraw.value = "绘制分级图";
    if(arguments.length>0)
    {
        $(btnDraw).bind("click",{flag:"IMSMAP",layername:arguments[0]},getIMSMap);
    }else
    {
        $(btnDraw).bind("click",{flag:"IMSMAP"},getIMSMap);
    }
    //$(btnDraw).bind("click",{flag:"IMSMAP"},getIMSMap);
    
    if(USER_ROLE_INDEX.indexOf("0002") == -1)
    {
        divButtons.appendChild(btnDraw);
    }
    else
    {
        divButtons.appendChild(txtClassNumber);
        divButtons.appendChild(btnClassify);
        divButtons.appendChild(btnDraw);
    }


    with($(divContent))
    {
        append(divButtons);
        append(divGraduations);
    }

    
    return divContent;
    
}

//单产制图与统计Div
function createUnitYeildDiv()
{
    var divGraduations = document.createElement("div");//刻度层
    var divButtons = document.createElement("div");//按钮层
    var divContent = document.createElement("div");//内容层
 
    //创建绘制地图的button元素
    var btnDrawByUnit = document.createElement("input");
    btnDrawByUnit.type = "button";
    btnDrawByUnit.value = "绘制作物单产分布图";
    //////10-20日添加--->    
    
    $(btnDrawByUnit).bind("click",{flag:"IMSMAP"},getCropMAP);
    
    //////<---10-20日添加
    

    
    
    //btnDraw.className = "next";

    //创建绘制分区县单产分布地图的button元素
    var btnDrawMapByCounty = document.createElement("input");
    btnDrawMapByCounty.type = "button";
    btnDrawMapByCounty.value = "绘制分区县单产空间分布图";
    
    //创建分区县统计单产数据的button元素
    var btnStatByCounty = document.createElement("input");
    btnStatByCounty.type = "button";
    btnStatByCounty.value = "分区县统计单产数据表"; 
    //////----->10-22日添加
    $(btnStatByCounty).bind("click",function (){
        alert("未完成");
    });//此事件需要修改11-5日
    
    //////<-----10-22日添加
      
    //////---->10-21日添加
    //创建分级数的文本框
    var txtLevelNum=document.createElement("input");
    txtLevelNum.type="text";   
    txtLevelNum.width="60";
    txtLevelNum.id="levelnum";
    //添加一个隐藏文本框记录
    var txtLevelHidden=document.createElement("input");
    txtLevelHidden.type="hidden";
    txtLevelHidden.id="levelhidde";
    txtLevelHidden.value=0;
    //创建设置分级按钮
    var butSetLevel=document.createElement("input");
    butSetLevel.type="button";
    butSetLevel.value="设置分级刻度";
    //绑定设置分级刻度的事件
    $(butSetLevel).bind("click",function(){
        var levelnum=txtLevelNum.value;
        if(levelnum.length==0||levelnum=="0")
        {
            $(divGraduations).empty();
            $(txtLevelNum).val("");            
            return;
        }else if(levelnum=="1")
        {
            alert("刻度至少要大于等于2");
            return;
        }

                var txtGraduationValueNames = new Array();
        var txtGraduationLabelNames = new Array();
        var txtGraduationColorNames = new Array();
        var baseText1 = "Graduation";
        var baseText2 = "Label";
        var baseText3 = "Color"
        for(var i = 0;i < levelnum;i++)
        {
            txtGraduationValueNames[i] = baseText1 + i;
            txtGraduationLabelNames[i] = baseText2 + i;
            txtGraduationColorNames[i] = baseText3 + i;
        }
        
        
        var txtGraduationValues = new Array();
        txtGraduationValues = createTexts(txtGraduationValueNames);
        
        var txtGraduationLabels = new Array();
        txtGraduationLabels = createTexts(txtGraduationLabelNames);
        
        var txtGraduationColors = new Array();
        txtGraduationColors = createTexts(txtGraduationColorNames);
        
        for(var i = 0; i < txtGraduationValues.length; i++)
        {
            $(txtGraduationValues[i]).width(135);
            $(txtGraduationLabels[i]).width(135);
            $(txtGraduationColors[i]).width(80);
        }
               
        
        var ColorIndex = 1;
        for(var i = 0; i < txtGraduationColors.length; i++)
        {
            $(txtGraduationColors[i]).bind("click",{id:i},function(event){
                ColorIndex = event.data.id;
            });
            
            $(txtGraduationColors[i]).ColorPicker({
	            onSubmit: function(hsb, hex, rgb) {		            
		            eval($('#Color' + ColorIndex)).val(hex);
		            
	            },
	            onBeforeShow: function () {
		            $(this).ColorPickerSetColor(this.value);
	            }
            });

        }
        
        var tableTitleString = new Array("农学参数刻度(数字)","遥感单产描述（文字）","颜色设置");
        var tableTitles = createTextNode(tableTitleString);
        
//*************************************************************************************************  12-9日修改       
//        var tableValue = new Array(txtGraduationValues,txtGraduationLabels,txtGraduationColors);        
//        var table = new DataTable(tableTitles,tableValue, 2);
        //定义设置默认选项的title列表
        var txtDefaultControl = new Array(" 默认值", " 默认值", " 默认值");
        
        //创建默认选项的textnode数组       
        var txtDefaultControlArray = createTextNode(txtDefaultControl);                                

        //定义设置默认选项的CheckBox ID列表
        var txtChkDefaultControlArray = new Array("defGraduations", "defLabels", "defColors");
        
        //定义设置默认选项的CheckBox数组                                
        var chkDefaultControlArray = createCheckboxs(txtChkDefaultControlArray); 
        
        for(var i = 0; i < chkDefaultControlArray.length; i++)
        {
            $(chkDefaultControlArray[i]).bind("click",function(){
                if($("#defGraduations").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",false);// = false;
                    }
                }
                
                if($("#defLabels").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",false);// = false;
                    }
                }
                if($("#defColors").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",false);// = false;
                    }
                }

            });        
        }
        
        var tableTitles2 = new Array();
        for (var i = 0; i < 3; i++)
        {
            tableTitles2[i] = document.createElement("span");
            with($(tableTitles2[i]))
            {
                append(tableTitles[i]);
                append("<br/>");

                append(chkDefaultControlArray[i]);
                append(txtDefaultControlArray[i]);
            }
            //tableTitles2[i].style.width = "120px";
        }   
        
        
             
        var tableValue = new Array(txtGraduationValues,txtGraduationLabels,txtGraduationColors);
        
        var table = new DataTable(tableTitles2,tableValue, 2);
//*************************************************************************************************<-----  12-9日修改  
        
        txtLevelHidden.value = levelnum;
        
        $(divGraduations).empty();
        divGraduations.appendChild(table);
        divGraduations.appendChild(txtLevelHidden);
    });
    
    //////<-----10-21日添加
    
    if(USER_ROLE_INDEX.indexOf("0002") == -1)
    {
        divButtons.appendChild(btnDrawByUnit);
    }
    else
    {
        with($(divButtons))
        {
            append(txtLevelNum);
            append("&nbsp;");
            append(butSetLevel);
            append("<br>");
            append(btnDrawByUnit);
            append("<br/>");
            append(btnDrawMapByCounty);
            append("<br/>");
            append(btnStatByCounty);
            append("<br/>");
        }
    }
    
    with($(divContent))
    {
        append(divButtons);
        append(divGraduations);
    }
    return divContent;

}


//农气模型选择Div
function createAgriModelSelectDiv()
{
    var divContent = document.createElement("div");
    
    var txtAtmosElement = document.createTextNode("气象因子");
    var txtModel = document.createTextNode("模型选择");
    
    
    //创建气象因子参数选择checkbox
    var checkboxAtmosphereNameArray = new Array("chkSunlight","chkRain","chkTemprature","chkHumidity");
    var checkboxAtmosphereArray = new Array();
    checkboxAtmosphereArray = createCheckboxs(checkboxAtmosphereNameArray);
    
    //创建农气模型选择checkbox
    var checkboxModelNameArray = new Array("chkModelA","chkModelB","chkModelC","chkModelD");
    var checkboxModelArray = new Array();
    checkboxModelArray = createCheckboxs(checkboxModelNameArray);
    
    
    var txtAtmosphereNames = new Array("平均气温","平均日照","降雨量","相对湿度");
    var txtAtmosphere = createTextNode(txtAtmosphereNames);
    
    var txtModelNames = new Array("A Model","B Model","C Model","D Model");
    var txtModels = createTextNode(txtModelNames);
    
    //空文本串
    var txtBlank = document.createTextNode("");
    
    var tableTitleArray = new Array(txtBlank,txtAtmosElement,txtBlank,txtModel);
    
    var tableValueArray = new Array(checkboxAtmosphereArray,txtAtmosphere,checkboxModelArray,txtModels);
    
    var modelTable = new DataTable(tableTitleArray,tableValueArray,2);
    
    $(divContent).append(modelTable);
//    $(divContent).css("min-height",180);

    return divContent;
}

//农气产量计算与统计
function createAgriCountyYeildDiv()
{
    var divContent = document.createElement("div");

    //创建分区县统计单产数据的button元素
    var btnStatByCounty = document.createElement("input");
    btnStatByCounty.type = "button";
    btnStatByCounty.value = "计算农气单产数据";
    
    $(divContent).append(btnStatByCounty);
//    $(divContent).css("min-height",180);

    return divContent;
     
}

//遥感单产算总产
function createRSUnit2GrossDiv()
{
    var divContent = document.createElement("div");

    //创建分区县统计单产数据的button元素
    var btnStatByCounty = document.createElement("input");
    btnStatByCounty.type = "button";
    btnStatByCounty.value = "遥感单产算总产";
    
    $(divContent).append(btnStatByCounty);
//    $(divContent).css("min-height",180);

    return divContent;

}


//农气单产算总产
function createAgri2GrossDiv()
{
    var divContent = document.createElement("div");

    //创建分区县统计单产数据的button元素
    var btnStatByCounty = document.createElement("input");
    btnStatByCounty.type = "button";
    btnStatByCounty.value = "农气单产算总产";
    
    $(divContent).append(btnStatByCounty);
//    $(divContent).css("min-height",180);

    return divContent;
}


//总产统计分析
function createGrossStatDiv()
{
    var divContent = document.createElement("div");

    //创建分区县统计单产数据的button元素
    var btnStatByCounty = document.createElement("input");
    btnStatByCounty.type = "button";
    btnStatByCounty.value = "农气单产与遥感单产对比分析";
    
    $(divContent).append(btnStatByCounty);
//    $(divContent).css("min-height",180);

    return divContent;

}

//******************************************************灾害监测—病虫害（宫）****************************************************************************************
function createRSIndexDiv_Disease()
{
    var divSelections = document.createElement("div");
    var divImages =  document.createElement("div");
    var divContent = document.createElement("div");
    var txtProvince = document.createTextNode("省（市、自治区）");
    var txtCounty = document.createTextNode("县（市、区）");
    var txtYear = document.createTextNode("年");
    
    var sltProvince = document.createElement("select");
    sltProvince.id = "sltProvince";
    var sltCounty = document.createElement("select");
    sltCounty.id = "sltCounty";
    var sltYear = document.createElement("select");
    sltYear.id = "sltYear";
    
    var thisDate = new Date();
    var thisYear = thisDate.getFullYear();
    for(var i = 0; i < 10; i++)
    {
        var yearOption = document.createElement("option");
        yearOption.value = thisYear - i;
        yearOption.text = thisYear - i;
        sltYear.options.add(yearOption);
    }
    
//    var ProvinceOptionText;
//    var ProvinceOptionValue;
//    
//    var countyOptionText;
//    var countyOptionValue;
    
    if (parseInt(USER_DISTRICT_ID) == 0 )
    {
        var ProvinceOptionText = new Array("北京","河北","吉林","黑龙江","江苏","山东","河南","湖南","浙江","新疆");
        var ProvinceOptionValue = new Array("1","5","9","10","11","16","17","19","12","31");
        var ProvinceOptions  = createOptions(ProvinceOptionValue,ProvinceOptionText);
        for(var i = 0; i < ProvinceOptionText.length; i++)
        {
            sltProvince.options.add(ProvinceOptions[i]);
        }
        fillCountySelect();
        $(sltProvince).bind("change",fillCountySelect);
    }
    else
    {
        if (parseInt(USER_DISTRICT_ID) == 1 )
        {
            
            var countyOptionText = new Array("全省（市、区）","大兴","通州","顺义","昌平","密云","平谷","怀柔","延庆","房山","丰台","门头沟","石景山","海淀","朝阳","中心四城区");
            var countyOptionValue = new Array("1","74","71","72","73","78","76","75","77","70","66","69","67","68","65","61");
            var countyOptions  = createOptions(countyOptionValue,countyOptionText);
            for(var i = 0; i < countyOptions.length; i++)
            {
                    sltCounty.options.add(countyOptions[i]);
            }            
        }
        else if(parseInt(USER_DISTRICT_ID) < 50)
        {
            //待修改，采用异步方式获得所有子节点及自己
            strUrl = "Services/getDistrictList.aspx";
            $.get(strUrl,{DISTID:USER_DISTRICT_ID,
                          TEMP:Math.random()
                          },
                          function(data){
                              var xmlDocument = data.documentElement;
                              var nDistricts = xmlDocument.childNodes.length;
                              var countyOptionText = new Array();
                              var countyOptionValue = new Array();
                              for(var i = 0; i < nDistricts; i++)
                              {
                                countyOptionText[i] = xmlDocument.childNodes[i].attributes[1].nodeValue;
                                countyOptionValue[i] = xmlDocument.childNodes[i].attributes[0].nodeValue;
                              }
                              var countyOptions  = createOptions(countyOptionValue,countyOptionText);
                              for(var i = 0; i < countyOptions.length; i++)
                              {
                                  sltCounty.options.add(countyOptions[i]);
                              }
                          });
        
        }
        else
        {
            var countyOptionText = new Array(USER_DISTRICT_NAME);
            var countyOptionValue = new Array(USER_DISTRICT_ID);
            var countyOptions  = createOptions(countyOptionValue,countyOptionText);
            for(var i = 0; i < countyOptions.length; i++)
            {
                    sltCounty.options.add(countyOptions[i]);
            }            
        }
    }
    

    
    var btnGetImageList = document.createElement("input");
    btnGetImageList.type = "button";
    btnGetImageList.value = "查询影像列表";
    
    //为获取遥感影像列表button绑定点击时间
    $(btnGetImageList).bind("click",function(){
        var selectedLocation = sltCounty.value;
        var selectedyear = sltYear.value;

        var strURL = "services/getImageList.aspx";
        
        //执行按钮点击后的事件，查找image list并生成元素
        $.get(strURL,{LOC:selectedLocation,YEAR:selectedyear,tmp:Math.random()},function(data){
            var xmlDocument = data.documentElement;
            
            var nImages = xmlDocument.childNodes.length;
            if (nImages == 0) 
            {
                $(divImages).empty();
                alert("没有符合您要求的影像数据！");
                return;
            }
            var imageId = new Array();
            var imageName = new Array();
            var BrowserType = getBrowserType();
            if(BrowserType == "MSIE")
            {
                for (var i = 0; i < nImages; i++)
                {
                    imageId[i] = xmlDocument.childNodes[i].attributes[0].nodeValue;
                    imageName[i] = xmlDocument.childNodes[i].attributes[1].nodeValue;
                }
            }
            else
            {
                for (var i = 0; i < (nImages -1)/2; i++)
                {
                    imageId[i] = xmlDocument.childNodes[i * 2 + 1].attributes[0].nodeValue;
                    imageName[i] = xmlDocument.childNodes[i * 2 + 1].attributes[1].nodeValue;
                }
            }
            var sltImageList = document.createElement("select");
            sltImageList.id = "ImageListSelect";

            var ImageOptions = createOptions(imageId,imageName);
            for (var i = 0; i < ImageOptions.length; i++)
            {
                sltImageList.options.add(ImageOptions[i]);
            }
            
            var btnOpenSamplePoints_disease = document.createElement("input");
            btnOpenSamplePoints_disease.type = "button";
            btnOpenSamplePoints_disease.value = "查看样点文件";
            //$(btnOpenSamplePoints).bind("click",{fileName:$(sltImageList).val()},loadSamplePointsTable);
            $(btnOpenSamplePoints_disease).bind("click",loadSamplePointsTable_disease);
            

            var btnGetIndex_disease = document.createElement("input");
            btnGetIndex_disease.type = "button";
            btnGetIndex_disease.value = "提取植被指数";
            //$(btnGetIndex).bind("click",{fileName:$(sltImageList).val()},calculateRSIndex);
            $(btnGetIndex_disease).bind("click",calculateRSIndex_disease);
         
            with($(divImages)){
                empty();
                append(sltImageList);
                append("<br/>");
                append(btnOpenSamplePoints_disease);
                append(btnGetIndex_disease);
            }

        });
    });
    
    with($(divSelections)){
        if(parseInt(USER_DISTRICT_ID)==0)
        {
            append(sltProvince);
            append(txtProvince);
        }
        append(sltCounty);
        append(txtCounty);
        append("<br/>");
        append(sltYear);
        append(txtYear);
        append("<br/>");
        append(btnGetImageList);
        
    }
    
    with($(divContent)){
//        css("min-height",180);
        append(divSelections);
        append(divImages);
//        height(330);
//        css("overflow","scroll");
    }
    
    return divContent;
}  

function createParamRelateDiv_Disease()
{
    var divContent = document.createElement("div");

    //定义表格的列名称
    var txtAgriTitle = document.createTextNode("农学参数");
    var txtRSIndexTitle = document.createTextNode("植被指数");
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义农学参数名称列表
    var txtAgriArray = new Array(   "总叶干重(LEAFGDW)",
                                    "叶面积指数（LAI）",
                                    "叶片含水量(MCL)",
                                    "鲜叶叶绿素总含量(CHL_AB)",
                                    "病虫害指数(DI)","","","","","","","","","","");
    //创建农学参数的textnode数组                                
    var txtNodeAgriArray = createTextNode(txtAgriArray);                                
    
    //定义农学参数的CheckBox ID列表
    var txtChkAgriArray = new Array("chkLEAFGDW",
                                    "chkLAI",
                                    "chkMCL",
                                    "chkCHL_AB",
                                    "chkDiseaseIndex","","","","","","","","","","");
    
    //定义农学参数的CheckBox数组                                
    var chkAgriArray = createCheckboxs(txtChkAgriArray); 
    
    //将名称与checkbox连接成span元素
    var spanAgriArray = new Array();
    for(var i = 0; i < txtChkAgriArray.length; i++)
    {
        spanAgriArray[i] = document.createElement("span");
        spanAgriArray[i].appendChild(chkAgriArray[i]);
        spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    
                                   
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    //定义植被指数名称列表
    var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G-SWIR", "G-SWIR2","EVI","RVI","ARVI","SAVI","MSAVI","DVI","RDVI");
    
    //创建植被指数的textnode数组       
    var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
    
    //定义植被指数的CheckBox ID列表
    var txtChkRSIndexArray = new Array("chkNDWI", "chkNDWI2", "chkNDVI", "chkNRI",	"chkNSI", "chkWI", "chkG-SWIR", "chkG-SWIR2", "chkEVI","chkRVI","chkARVI","chkSAVI","chkMSAVI","chkDVI","chkRDVI");
    
    //定义植被指数的CheckBox数组                                
    var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
    
    //将名称与checkbox连接成span元素
    var spanRSIndexArray = new Array();
    for(var i = 0; i < txtRSIndexArray.length; i++)
    {
        spanRSIndexArray[i] = document.createElement("span");
        spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
        spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////

    
    //创建绘制地图的button元素?????计算相关系数
    var btnCalcuRxy = document.createElement("input");
    btnCalcuRxy.type = "button";
    btnCalcuRxy.value = "计算相关系数";
    $(btnCalcuRxy).bind("click",function(){
        var selectedAgriParams = "";
        var selectedRSIndex = "";
        for(var i = 0; i < chkRSIndexArray.length; i++)
        {
            if(chkAgriArray[i].checked == true)
            {
                selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
            }
            if(chkRSIndexArray[i].checked == true)
            {
                selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
            }

        }
        if(selectedAgriParams.length == 0) {alert("您没有选择农学参数，请您先选择至少一项农学参数！");return;}
        if(selectedRSIndex.length == 0) {alert("您没有选择植被指数，请您先选择至少一项植被指数！");return;}
        selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
        selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
        
        var imageId = $("#ImageListSelect").val();
        if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
        
        calculateRelatedCoefficient_Disease(selectedAgriParams,selectedRSIndex);
    
    });
    

    //将上面生成的元素组织成表格形式
    var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle);
    var paramTableValue = new Array(spanAgriArray,spanRSIndexArray);
    var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
    
    //将表格和button添加到div
    with($(divContent)){
        append(paramTable);
        append(btnCalcuRxy);
//        css("min-height",180);
//        height(330);
//        css("overflow","scroll");
    }

    return divContent;

}


//模型选择Div
function createModelSelectDiv_Disease()
{
    var divContent = document.createElement("div");

    var txtModelName = document.createTextNode("模型名称");
    var txtModelEquation = document.createTextNode("模型方程");
    var txtModelR_Squared =  document.createTextNode("拟合优度");
    var txtModelSelect =  document.createTextNode("选择模型");
    
    var txtLine = document.createTextNode("线性模型");
    var txtExp = document.createTextNode("指数模型");
    var txtLn = document.createTextNode("对数模型");
    
//    var txtChoice1 = document.createTextNode("选择");
//    var txtChoice2 = document.createTextNode("选择");
//    var txtChoice3 = document.createTextNode("选择");
    
    var txtTitleNames = new Array(txtLine,txtExp,txtLn);

    //创建模型选择的radio元素
    var modelRadioNameArray = new Array("radioLine","radioExp","radioLn");
    
    var modelRradioArray = new Array();
    modelRradioArray = createRadios(modelRadioNameArray,radioCheckModel);
    
//    //创建参数选择checkbox
//    var checkboxNameArray = new Array("chkLAI","chkBiomass","chkNDVI","chkNDWI");
//    var checkboxArray = new Array();
//    checkboxArray = createCheckboxs(checkboxNameArray);

    //空文本串
    var txtBlank = document.createTextNode("");

    //记录模型方程的文本框
    var txtTextNameArray = new Array("txtLine","txtExp","txtLn");
    var txtTextArray = new Array();
    txtTextArray = createTexts(txtTextNameArray);
    
    //记录拟合优度的文本框
    txtTextNameArray = new Array("txtLineR","txtExpR","txtLnR");
    var txtRArray = new Array();
    txtRArray = createTexts(txtTextNameArray);
    
    for(var i = 0; i < txtTextArray.length; i++)
    {
//        txtTextArray[i].disabled ="disabled";
//        txtRArray[i].disabled ="disabled";
        $(txtTextArray[i]).bind("change",{elem:$(txtTextArray[i]).attr("id")},function(event){
            alert("该处仅用于显示计算结果，不能接受任何数据输入！");
            //$(txtTextArray[i]).val("");
            eval($('#' + event.data.elem)).val("");
        });
        
        $(txtRArray[i]).bind("change",{elem:$(txtRArray[i]).attr("id")},function(event){
            alert("该处仅用于显示计算结果，不能接受任何数据输入！");
            //$(txtRArray[i]).val("");
            eval($('#' + event.data.elem)).val("");
        });
    }
    
    
    //创建计算模型的button元素
    var calcuButtonNameArray = new Array("建立模型");
    calcuButtonArray = createButtons(calcuButtonNameArray,"");
    $(calcuButtonArray).bind("click",resolveModelParam_Disease);
    
//    var calcuButtonNameArray = new Array("计算","计算","计算");
//    var calcuButtonArray = new Array();
//    calcuButtonArray = createButtons(calcuButtonNameArray,"");
//    for(i = 0;i < calcuButtonArray.length; i++)
//    {
//        $(calcuButtonArray[i]).bind("click",{id:i},resolveModelParam);
//    }

    //div content3的元素表格
    var modelTableTitle = new Array(txtModelName,txtModelEquation,txtModelR_Squared,txtModelSelect);
//    var modelTableValue1 = new Array(txtLine,calcuButtonArray[0],txtTextArray[0],modelRradioArray[0]);
//    var modelTableValue2 = new Array(txtExp,calcuButtonArray[1],txtTextArray[1],modelRradioArray[1]);
//    var modelTableValue3 = new Array(txtLn,calcuButtonArray[2],txtTextArray[2],modelRradioArray[2]);
//    var modelTableValue4 = new Array(txtBlank,previousButtonArray[1],txtBlank,nextButtonArray[2]);


//    var modelTableValueAll = new Array(modelTableValue1,modelTableValue2,modelTableValue3);
    var modelTableValueAll = new Array(txtTitleNames,txtTextArray,txtRArray,modelRradioArray);
    var modelTable = new DataTable(modelTableTitle,modelTableValueAll,2);


    with($(divContent))
    {
        append(modelTable);
        append(calcuButtonArray);
//        css("min-height",180);
//        append("<br/><br/><br/><br/>");
//        height(330);
//        css("overflow","scroll");
    }
    
    return divContent;

}

//长势绘图Div
function createDrawGrowingGraphDiv_Disease()
{
    var divGraduations = document.createElement("div");
//    divGraduations.id = "Graduations";
    var divButtons = document.createElement("div");
    var divContent = document.createElement("div");
 
    var txtClassNumber = document.createElement("input");
    txtClassNumber.type = "text";
    txtClassNumber.width = "72";
    txtClassNumber.id = "classNumber";
    
    //设置一个隐藏文本框来记录分级设置的级别数
    var hiddenTextNumber = document.createElement("input");
    hiddenTextNumber.id = "GraduationNumber";
    hiddenTextNumber.type = "hidden";
    hiddenTextNumber.value = 0;

    
    //创建绘制地图的button元素
    var btnClassify = document.createElement("input");
    btnClassify.type = "button";
    btnClassify.value = "设置分级刻度";
//    btnClassify.attachEvent("onclick",function(){
    $(btnClassify).bind("click",function(){
        //待添加处理用户权限的处理...........////////////////////////////////////////////////////////////////////////////
        var classNumber = txtClassNumber.value;
        if(classNumber.length == 0 || classNumber == "0") 
        {
            $(divGraduations).empty();
            $(txtClassNumber).val("");

            //alert("请在左侧文本框中填写分级刻度数！");
            return;
        }
        else if(classNumber == "1")
        {
            alert("分级刻度数至少应该大于等于2！");
            return;
        }
        var txtGraduationValueNames = new Array();
        var txtGraduationLabelNames = new Array();
        var txtGraduationColorNames = new Array();
        var baseText1 = "Graduation";
        var baseText2 = "Label";
        var baseText3 = "Color"
        for(var i = 0;i < classNumber;i++)
        {
            //txtGraduationNames[i] = baseText1 + i;
            txtGraduationValueNames[i] = baseText1 + i;
            txtGraduationLabelNames[i] = baseText2 + i;
            txtGraduationColorNames[i] = baseText3 + i;
        }
        
        //var txtGraduations = new Array();
        //txtGraduations =createTextNode(txtGraduationNames)
        
        var txtGraduationValues = new Array();
        txtGraduationValues = createTexts(txtGraduationValueNames);
        
        var txtGraduationLabels = new Array();
        txtGraduationLabels = createTexts(txtGraduationLabelNames);
        
        var txtGraduationColors = new Array();
        txtGraduationColors = createTexts(txtGraduationColorNames);
        
        for(var i = 0; i < txtGraduationValues.length; i++)
        {
            $(txtGraduationValues[i]).width(120);
            $(txtGraduationLabels[i]).width(120);
            $(txtGraduationColors[i]).width(120);
        }
//        txtGraduationLabels[0].style.visibility = "hidden";
//        txtGraduationColors[0].style.visibility = "hidden";
               
        
        var ColorIndex = 1;
        for(var i = 0; i < txtGraduationColors.length; i++)
        {
            $(txtGraduationColors[i]).bind("click",{id:i},function(event){
                ColorIndex = event.data.id;
            });
            
            $(txtGraduationColors[i]).ColorPicker({
	            onSubmit: function(hsb, hex, rgb) {
		            //$('#Label' + i).val(hex);
		            //alert(labelIndex);
		            eval($('#Color' + ColorIndex)).val(hex);
		            
	            },
	            onBeforeShow: function () {
		            $(this).ColorPickerSetColor(this.value);
	            }
            });
//            .bind('keyup', function(){
//	            $(this).ColorPickerSetColor(this.value);
//            })
        }
        
        var tableTitleString = new Array("农学参数刻度(数字)","病害状况描述（文字）","颜色设置");
        var tableTitles = createTextNode(tableTitleString);
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        //定义设置默认选项的title列表
        var txtDefaultControl = new Array(" 默认值", " 默认值", " 默认值");
        
        //创建默认选项的textnode数组       
        var txtDefaultControlArray = createTextNode(txtDefaultControl);                                

        //定义设置默认选项的CheckBox ID列表
        var txtChkDefaultControlArray = new Array("defGraduations", "defLabels", "defColors");
        
        //定义设置默认选项的CheckBox数组                                
        var chkDefaultControlArray = createCheckboxs(txtChkDefaultControlArray); 
        
        for(var i = 0; i < chkDefaultControlArray.length; i++)
        {
            $(chkDefaultControlArray[i]).bind("click",function(){
                if($("#defGraduations").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationValues[j]).attr("disabled",false);// = false;
                    }
                }
                
                if($("#defLabels").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationLabels[j]).attr("disabled",false);// = false;
                    }
                }
                if($("#defColors").attr("checked") == true)
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",true);// = true;
                    }
                }
                else
                {
                    for(var j = 0; j < txtGraduationValues.length; j++)
                    {
                        $(txtGraduationColors[j]).attr("disabled",false);// = false;
                    }
                }

            });        
        }
        
        var tableTitles2 = new Array();
        for (var i = 0; i < 3; i++)
        {
            tableTitles2[i] = document.createElement("span");
            with($(tableTitles2[i]))
            {
                append(tableTitles[i]);
                append("<br/>");

                append(chkDefaultControlArray[i]);
                append(txtDefaultControlArray[i]);
            }
            //tableTitles2[i].style.width = "120px";
        }   
        
        
             
        var tableValue = new Array(txtGraduationValues,txtGraduationLabels,txtGraduationColors);
        
        var table = new DataTable(tableTitles2,tableValue, 2);
        
        

        //var table2 = new DataTable(tableTitles2);


        
//        var table = new DataTable(txtGraduations,tableValue, 1);
//        $("#table").attr("id","Graduations");

        hiddenTextNumber.value = classNumber;
        
        $(divGraduations).empty();
        divGraduations.appendChild(table);
        //divGraduations.appendChild(table2);
        divGraduations.appendChild(hiddenTextNumber);
    });


    //创建绘制地图的button元素
    var btnDraw = document.createElement("input");
    btnDraw.type = "button";
    btnDraw.value = "绘制病害分级图";
    $(btnDraw).bind("click",{flag:"IMSMAP"},getIMSMap_Disease);
    
    if(USER_ROLE_INDEX.indexOf("0002") == -1)
    {
        divButtons.appendChild(btnDraw);
    }
    else
    {
        divButtons.appendChild(txtClassNumber);
        divButtons.appendChild(btnClassify);
        divButtons.appendChild(btnDraw);
    }


    with($(divContent))
    {
        append(divButtons);
        append(divGraduations);
    }

    
    return divContent;
    
}
//********************************************************************************************************************************************************

